package com.china.zhuoyue.ui.activity.user

import android.view.View
import com.bigkoo.pickerview.view.OptionsPickerView
import com.china.zhuoyue.api.login.launchUILogin
import com.china.zhuoyue.databinding.ActivityAddAuthBinding
import com.china.zhuoyue.ui.base.BaseActivity
import com.china.zhuoyue.ui.bean.picker.BaseCityBean
import com.china.zhuoyue.ui.helper.PickerViewHelper

class AddAuthActivity : BaseActivity<ActivityAddAuthBinding>() {
    private var mCityOptionsPickerView: OptionsPickerView<BaseCityBean>? = null
    private var mProvBean: BaseCityBean? = null
    private var mCityBean: BaseCityBean? = null
    private var mCounBean: BaseCityBean? = null
    override fun initView() {
        bindViewClick(vb.llAuthCity)
    }

    override fun onClick(v: View?) {
        when (v) {
            vb.llAuthCity -> {
                if (mCityOptionsPickerView == null) {
                    launchUILogin({
                        PickerViewHelper.createProvCityAreaPickerView(mThis, mOnOptionsSelectListener = { option1, option2, option3 ->
                            mProvBean = PickerViewHelper.getCityOptions1ByPosition(option1)
                            mCityBean = PickerViewHelper.getCityOptions2ByPosition(option1, option2)
                            mCounBean = PickerViewHelper.getCityOptions3ByPosition(option1, option2, option3)
                            vb.tvAuthCity.text = "${mProvBean?.name}${mCityBean?.name}${mCounBean?.name}"
                        }) { mCityOptionsPickerView = it; mCityOptionsPickerView!!.show() }
                    })
                } else mCityOptionsPickerView?.show()
            }
        }
    }
}